// src/api/system/dict.ts
import request from '@/utils/request'
import type { DictType, DictData, DictQuery, DictOption } from '@/types/system/dict'

// 获取字典类型列表
export function listDict(query: DictQuery) {
  return request({
    url: '/system/dict/list',
    method: 'get',
    params: query,
  })
}

// 新增字典类型
export function addDict(data: DictType) {
  return request({
    url: '/system/dict',
    method: 'post',
    data,
  })
}

// 修改字典类型
export function updateDict(data: DictType) {
  return request({
    url: '/system/dict',
    method: 'put',
    data,
  })
}

// 删除字典类型
export function deleteDict(id: number) {
  return request({
    url: `/system/dict/${id}`,
    method: 'delete',
  })
}

// 获取字典数据列表
export function listDictData(query: DictQuery) {
  return request({
    url: '/system/dict/data/list',
    method: 'get',
    params: query,
  })
}

// 新增字典数据
export function addDictData(data: DictData) {
  return request({
    url: '/system/dict/data',
    method: 'post',
    data,
  })
}

// 修改字典数据
export function updateDictData(data: DictData) {
  return request({
    url: '/system/dict/data',
    method: 'put',
    data,
  })
}

// 删除字典数据
export function deleteDictData(id: number) {
  return request({
    url: `/system/dict/data/${id}`,
    method: 'delete',
  })
}
